//
//  NSString+TGHelper.m
//  TongGuanLease
//
//  Created by 张奇 on 2022/5/6.
//

#import "NSString+TGHelper.h"

@implementation NSString (TGHelper)

- (NSString*)changeIDCard {
    if (self==nil || self.length<18) {
        return nil;
    }
    NSString *string = [self stringByReplacingCharactersInRange:NSMakeRange(6,8) withString:@"********"];
    return string;
}


-(NSString *)beyondDisPoseWithIndex:(NSInteger)index {
    if (self.length > 0) {
        if (self.length <= index) {
            return self;
        }else if(self.length > index){
            NSRange range =  [self rangeOfComposedCharacterSequenceAtIndex:index];
            NSString *str = nil;
            if (range.length>1) {
                str = [self substringToIndex:range.location+range.length];
            }else {
                str = [self substringToIndex:range.location];
            }
            return [NSString stringWithFormat:@"%@..",str];
        }
    }
    return @"";
}

+ (NSString *)getAppVersions{
    
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    // app版本
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
#if DEBUG
    NSString *buildCode = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    app_Version = [NSString stringWithFormat:@"%@(%@)", app_Version, buildCode];
#endif
    return app_Version;
}


@end
